package com.myapp.api.mapper;

import com.myapp.api.entity.Major;
import org.apache.ibatis.jdbc.SQL;

public class MajorSqlProvider {

    public String insertSelective(Major record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("major");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getMid() != null) {
            sql.VALUES("Mid", "#{mid,jdbcType=VARCHAR}");
        }
        
        if (record.getDid() != null) {
            sql.VALUES("Did", "#{did,jdbcType=VARCHAR}");
        }
        
        if (record.getMname() != null) {
            sql.VALUES("Mname", "#{mname,jdbcType=VARCHAR}");
        }
        
        if (record.getMinfo() != null) {
            sql.VALUES("Minfo", "#{minfo,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.VALUES("CreateTime", "#{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.VALUES("UpdateTime", "#{updatetime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Major record) {
        SQL sql = new SQL();
        sql.UPDATE("major");
        
        if (record.getMid() != null) {
            sql.SET("Mid = #{mid,jdbcType=VARCHAR}");
        }
        
        if (record.getDid() != null) {
            sql.SET("Did = #{did,jdbcType=VARCHAR}");
        }
        
        if (record.getMname() != null) {
            sql.SET("Mname = #{mname,jdbcType=VARCHAR}");
        }
        
        if (record.getMinfo() != null) {
            sql.SET("Minfo = #{minfo,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.SET("CreateTime = #{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.SET("UpdateTime = #{updatetime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}